import sys, os
try:
        import pygtk
        pygtk.require("2.0")
except:
        pass
try:
        import gtk
        import gtk.glade
except:
        sys.exit(1)
from core.base import DCPPPart

class SettingsDialog(DCPPPart):
	def __init__(self, parent):
		DCPPPart.__init__(self, parent)
		self._widget = self.parent.wtree.get_widget('SettingsDialog')
		self.parent._fastConnect("SettingsOk", "clicked", self._ok)
		self.parent._fastConnect("SettingsCancel", 'clicked', self.hide)

	def show(self, *args, **kwargs):
		self._load()
		self._widget.show()

	def hide(self, *args, **kwargs):
		self._widget.hide()

	def _ok(self, *args, **kwargs):
		self.hide()
		print self.parent.wtree.get_widget("SettingsNickname").get_text()
		print self.parent.wtree.get_widget("SettingsInterest").get_text()
		print self.parent.wtree.get_widget("SettingsEmail").get_text()
		print self.parent.wtree.get_widget("SettingsSpeed").active
		print self.parent.wtree.get_widget("SettingsFinished")
		print self.parent.wtree.get_widget("SettingsUnfinished")

	def _load(self, *args, **kwargs):
		self.parent.wtree.get_widget("SettingsNickname").set_text(self.settings.get('nickname', ""))
		self.parent.wtree.get_widget("SettingsInterest").set_text(self.settings.get('infointerest',""))
		self.parent.wtree.get_widget("SettingsEmail").set_text(self.settings.get("infoemail",""))
